package com.twu.biblioteca;

import java.util.ListIterator;

/**
 * Created with IntelliJ IDEA.
 * User: dbelsey
 * Date: 30/01/13
 * Time: 21:02
 */
public class MovieLibraryCollection extends LibraryCollection {

//   TODO: consider scheduling for deletion / cleanup in next refactoring phase: adds no new functionality compared to library

    public MovieLibraryCollection(){
        super();
    }

    public void populateLibrary(){
        // TODO: read this in from a file?
        libraryContents.add(new Movie("Sholay","1975","Ramesh Sippy",0));
        libraryContents.add(new Movie("Test Movie 2","1989","Test Director 2",8));
        libraryContents.add(new Movie("Test Movie 3","1969","Test Director 3",5));
        libraryContents.add(new Movie("Test Movie 4","1993","Test Director 4",6));
        libraryContents.add(new Movie("Test Movie 5","1997","Test Director 5",5));
        libraryContents.add(new Movie("Test Movie 6","2008","Test Director 6",9));
        libraryContents.add(new Movie("Test Movie 7","2005","Test Director 7",10));
        libraryContents.add(new Movie("Test Movie 8","2011","Test Director 8",8));
        libraryContents.add(new Movie("Test Movie 9","1991","Test Director 9",2));
        libraryContents.add(new Movie("Test Movie 10","1970","Test Director 10",4));
        libraryContents.add(new Movie("Test Movie 11","2008","Test Director 11",1));
        libraryContents.add(new Movie("Test Movie 12","2005","Test Director 12",9));
        libraryContents.add(new Movie("Test Movie 13","1995","Test Director 13",10));
        libraryContents.add(new Movie("Test Movie 14","2007","Test Director 14",6));
        libraryContents.add(new Movie("Test Movie 15","2009","Test Director 15",4));
    }

    public String getLibraryContentsToString(){
        ListIterator<LibraryItem> libraryIterator = libraryContents.listIterator();
        String libraryList = new String("List of Movies: \n Title \t\t Year \t\t Director \t\t Rating");

        while(libraryIterator.hasNext()){
            Movie thisMovie = (Movie) libraryIterator.next();
            libraryList = libraryList + System.getProperty("line.separator") + (libraryIterator.nextIndex()) +". "+ thisMovie.getTitle();
            libraryList = libraryList + "\t" + thisMovie.getYear();
            libraryList = libraryList + "\t" + thisMovie.getDirector();
            libraryList = libraryList + "\t" + thisMovie.getRating();
        }
        return libraryList;
    }


}
